from common.exception.biz_error_type import BizErrorType

"""
自定义异常基类

Copyright (C) chengpeng.hu. All Rights Reserved

@Author : chengpeng.hu
@Date : 2024
"""


class BaseBizException(Exception):
    def __init__(self, error_type: BizErrorType, msg=None, cause=None):
        super().__init__(msg)
        self.error_type = error_type
        self.cause = cause

    def get_error_type(self):
        return self.error_type

    def __str__(self):
        return f"[{self.error_type.get_code()}]{','.join(filter(None, [self.error_type.get_msg(), super().__str__()]))}"
